/**
 * 
 */
package dms.dto;

import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import dms.model.Building;
import dms.model.role.Student;

/**
 * @author 李健
 *
 */
public class DormitoryDTO extends ActionForm {
	private Long id;
	private Long building;
	private String telephone;
	private String name;
	private String description;
	private Integer capacity;
	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}
	/**
	 * @return the building
	 */
	public Long getBuilding() {
		return building;
	}
	/**
	 * @param building the building to set
	 */
	public void setBuilding(Long building) {
		this.building = building;
	}
	/**
	 * @return the telephone
	 */
	public String getTelephone() {
		return telephone;
	}
	/**
	 * @param telephone the telephone to set
	 */
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}
	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	/**
	 * @return the capacity
	 */
	public Integer getCapacity() {
		return capacity;
	}
	/**
	 * @param capacity the capacity to set
	 */
	public void setCapacity(Integer capacity) {
		this.capacity = capacity;
	}
	
	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		
		ActionErrors errors = new ActionErrors();
		if (this.building == null) {
			errors.add("errors", new ActionMessage("缺少楼栋Id", false));
		}
		if (this.name == null || this.name.length() == 0) {
			errors.add("errors", new ActionMessage("缺少寝室名称", false));
		}
		if (this.telephone == null || this.telephone.length() == 0) {
			errors.add("errors", new ActionMessage("缺少寝室电话号码", false));
		}
		if (this.capacity == null || this.capacity == 0) {
			errors.add("errors", new ActionMessage("缺少寝室可住人数"));
		}
		
		return errors;
	}
	
	@Override
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		this.building = null;
		this.name = null;
		this.telephone = null;
		this.capacity = null;
		this.description = null;
		this.id = null;
	}
}
